﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Web;
using DiarySocial.Models;

namespace DiarySocial.ViewModels
{
    public class TimeLineItemVM
    {
        public TimeLineItemVM()
        {
            this.Comments = new List<CommentVM>();
        }
        public int Id { get; set; }
        public string Body { get; set; }
        public AuthorVM Author { get; set; }
        public int LikeCount { get; set; }
        public int CommentCount { get; set; }
        public bool IsLiked { get; set; }
        public int Privacy { get; set; }
        public ICollection<CommentVM> Comments { get; set; }
        public DateTime Time { get; set; }
    }
    public class AuthorVM
    {
        public string Avatar { get; set; }
        public string Name { get; set; }
        public string AuthorLink { get; set; }

        public AuthorVM()
        {
            Avatar = AppConst.DEFAULT_AVATAR_URL;
            Name = AppConst.ANONYMOUS_NAME;
            AuthorLink = AppConst.NULL_URL;
        }

        public AuthorVM(string name)
        {
            Avatar = AppConst.DEFAULT_AVATAR_URL;
            AuthorLink = "/Diary/Profile/" + name;
            this.Name = name;
        }

        public AuthorVM(string name, int privacy)
        {
            Avatar = AppConst.DEFAULT_AVATAR_URL;
            AuthorLink = "/Diary/Profile/" + name;
            if (privacy == (int)PrivacyType.Anonymous)
            {
                AuthorLink = AppConst.NULL_URL;
            }
            else
            {
                this.Name = name;
            }
        }
    }

    public class CommentVM
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public DateTime Time { get; set; }
        public AuthorVM CommentAuthor { get; set; }
    }
}